#pragma once
#include <iostream>
#include <fstream>
#include <sstream>
#include <list>
#include <string>
#include <time.h>

#include "Transaction.h"
#include "Expense.h"
#include "Income.h"
#include "Transfer.h"
#include "History.h"
#include "Wallet.h"
#include "Manager.h"
#include "Action.h"

#include "Add Transaction.h"
#include "Add Account.h"
#include "Add Category.h"
#include "Edit Account Name.h"
#include "Edit Category Name.h"
#include "Edit Transaction.h"


#include "msclr\marshal_cppstd.h"

namespace CS2103v01 {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;

	using namespace std;
	using namespace Microsoft::Office::Interop;

	/// <summary>
	/// Summary for MainWindow
	/// </summary>
	public ref class MainWindow : public System::Windows::Forms::Form
	{
	public:
		MainWindow(void)
		{
			InitializeComponent();
			//
			//TODO: Add the constructor code here

			//set system timing
			rawSysTime = new time_t;
			time(rawSysTime);

			//initialize History toShow
			toShow = new History;
			A = new Wallet;
			TM = Manager::getOne(A->getTranList(), A->getCatList(), A->getAccList(), A->getAccDep(), A->getSNAddr());
			retrieveALL("<>?");
			//
		}

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~MainWindow()
		{
			if (components)
			{
				delete components;
			}
		}


	protected: 

	private:
		/// <summary>
		/// Required designer variable.

		time_t *rawSysTime;
		Wallet *A;
		Manager *TM;
		History *toShow;
		/// </summary>

	private: System::Windows::Forms::Label^  label1;
	private: System::Windows::Forms::TabControl^  tabControl1;
	private: System::Windows::Forms::TabPage^  tabPage1;
	private: System::Windows::Forms::TabPage^  tabPage2;
	private: System::Windows::Forms::TabPage^  tabPage3;
	private: System::Windows::Forms::TabPage^  tabPage4;
	private: System::Windows::Forms::Button^  button2;
	private: System::Windows::Forms::Label^  label11;
	private: System::Windows::Forms::Label^  label10;
	private: System::Windows::Forms::Label^  label9;
	private: System::Windows::Forms::Label^  label8;
	private: System::Windows::Forms::Button^  button1;
	private: System::Windows::Forms::Label^  label6;
	private: System::Windows::Forms::Label^  label5;
	private: System::Windows::Forms::Label^  label3;
	private: System::Windows::Forms::Label^  label2;
	private: System::Windows::Forms::ComboBox^  comboBox1;
	private: System::Windows::Forms::Label^  label15;
	private: System::Windows::Forms::Label^  label14;
	private: System::Windows::Forms::DateTimePicker^  dateTimePicker2;
	private: System::Windows::Forms::Label^  label13;
	private: System::Windows::Forms::Label^  label12;
	private: System::Windows::Forms::DateTimePicker^  dateTimePicker1;
	private: System::Windows::Forms::Button^  button3;
	private: System::Windows::Forms::ComboBox^  comboBox2;
	private: System::Windows::Forms::DataGridView^  dataGridView1;
	private: System::Windows::Forms::GroupBox^  groupBox1;
	private: System::Windows::Forms::Label^  label16;
	private: System::Windows::Forms::DataGridView^  dataGridView2;
	private: System::Windows::Forms::Button^  button5;
	private: System::Windows::Forms::Button^  button4;
	private: System::Windows::Forms::Label^  label19;
	private: System::Windows::Forms::Label^  label18;
	private: System::Windows::Forms::Label^  label17;
	private: System::Windows::Forms::DataGridView^  dataGridView3;
	private: System::Windows::Forms::Label^  label24;
	private: System::Windows::Forms::Label^  label23;
	private: System::Windows::Forms::GroupBox^  groupBox2;
	private: System::Windows::Forms::DateTimePicker^  dateTimePicker3;
	private: System::Windows::Forms::Button^  button7;
	private: System::Windows::Forms::Label^  label21;
	private: System::Windows::Forms::DateTimePicker^  dateTimePicker4;
	private: System::Windows::Forms::Label^  label22;
	private: System::Windows::Forms::Label^  label20;
	private: System::Windows::Forms::Button^  button9;
	private: System::Windows::Forms::Button^  button8;
	private: System::Windows::Forms::Button^  button6;
	private: System::Windows::Forms::DataGridViewTextBoxColumn^  Column8;
	private: System::Windows::Forms::DataGridViewTextBoxColumn^  Column9;
	private: System::Windows::Forms::DataGridViewTextBoxColumn^  Column10;
	private: System::Windows::Forms::DataGridViewTextBoxColumn^  Column5;
	private: System::Windows::Forms::DataGridViewTextBoxColumn^  Column6;
	private: System::Windows::Forms::DataGridViewButtonColumn^  Column7;
	private: System::Windows::Forms::Timer^  timer1;
	private: System::Windows::Forms::Button^  button10;
	private: System::Windows::Forms::Button^  button13;
	private: System::Windows::Forms::Button^  button14;
	private: System::Windows::Forms::Button^  button15;
	private: System::Windows::Forms::Button^  button16;







	private: System::Windows::Forms::Label^  label32;
	private: System::Windows::Forms::Button^  button17;
	private: System::Windows::Forms::Button^  button18;
private: System::Windows::Forms::DataGridViewTextBoxColumn^  Column1;
private: System::Windows::Forms::DataGridViewTextBoxColumn^  Column12;
private: System::Windows::Forms::DataGridViewTextBoxColumn^  Column13;
private: System::Windows::Forms::DataGridViewTextBoxColumn^  Column4;
private: System::Windows::Forms::DataGridViewTextBoxColumn^  Column11;
private: System::Windows::Forms::DataGridViewTextBoxColumn^  Column2;
private: System::Windows::Forms::DataGridViewTextBoxColumn^  Column3;

	private: System::ComponentModel::IContainer^  components;



#pragma region Windows Form Designer generated code
			 /// <summary>
			 /// Required method for Designer support - do not modify
			 /// the contents of this method with the code editor.
			 /// </summary>
			 void InitializeComponent(void)
			 {
				 this->components = (gcnew System::ComponentModel::Container());
				 System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(MainWindow::typeid));
				 this->label1 = (gcnew System::Windows::Forms::Label());
				 this->tabControl1 = (gcnew System::Windows::Forms::TabControl());
				 this->tabPage1 = (gcnew System::Windows::Forms::TabPage());
				 this->button2 = (gcnew System::Windows::Forms::Button());
				 this->label11 = (gcnew System::Windows::Forms::Label());
				 this->label10 = (gcnew System::Windows::Forms::Label());
				 this->label9 = (gcnew System::Windows::Forms::Label());
				 this->label8 = (gcnew System::Windows::Forms::Label());
				 this->button1 = (gcnew System::Windows::Forms::Button());
				 this->label6 = (gcnew System::Windows::Forms::Label());
				 this->label5 = (gcnew System::Windows::Forms::Label());
				 this->label3 = (gcnew System::Windows::Forms::Label());
				 this->label2 = (gcnew System::Windows::Forms::Label());
				 this->tabPage2 = (gcnew System::Windows::Forms::TabPage());
				 this->label32 = (gcnew System::Windows::Forms::Label());
				 this->button16 = (gcnew System::Windows::Forms::Button());
				 this->button15 = (gcnew System::Windows::Forms::Button());
				 this->button14 = (gcnew System::Windows::Forms::Button());
				 this->button13 = (gcnew System::Windows::Forms::Button());
				 this->groupBox1 = (gcnew System::Windows::Forms::GroupBox());
				 this->button17 = (gcnew System::Windows::Forms::Button());
				 this->label13 = (gcnew System::Windows::Forms::Label());
				 this->label16 = (gcnew System::Windows::Forms::Label());
				 this->dateTimePicker1 = (gcnew System::Windows::Forms::DateTimePicker());
				 this->dateTimePicker2 = (gcnew System::Windows::Forms::DateTimePicker());
				 this->button3 = (gcnew System::Windows::Forms::Button());
				 this->label14 = (gcnew System::Windows::Forms::Label());
				 this->comboBox2 = (gcnew System::Windows::Forms::ComboBox());
				 this->label15 = (gcnew System::Windows::Forms::Label());
				 this->comboBox1 = (gcnew System::Windows::Forms::ComboBox());
				 this->dataGridView1 = (gcnew System::Windows::Forms::DataGridView());
				 this->label12 = (gcnew System::Windows::Forms::Label());
				 this->tabPage3 = (gcnew System::Windows::Forms::TabPage());
				 this->button10 = (gcnew System::Windows::Forms::Button());
				 this->dataGridView2 = (gcnew System::Windows::Forms::DataGridView());
				 this->Column5 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
				 this->Column6 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
				 this->Column7 = (gcnew System::Windows::Forms::DataGridViewButtonColumn());
				 this->button5 = (gcnew System::Windows::Forms::Button());
				 this->button4 = (gcnew System::Windows::Forms::Button());
				 this->label19 = (gcnew System::Windows::Forms::Label());
				 this->label18 = (gcnew System::Windows::Forms::Label());
				 this->label17 = (gcnew System::Windows::Forms::Label());
				 this->tabPage4 = (gcnew System::Windows::Forms::TabPage());
				 this->button9 = (gcnew System::Windows::Forms::Button());
				 this->button8 = (gcnew System::Windows::Forms::Button());
				 this->button6 = (gcnew System::Windows::Forms::Button());
				 this->dataGridView3 = (gcnew System::Windows::Forms::DataGridView());
				 this->Column8 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
				 this->Column9 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
				 this->Column10 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
				 this->label24 = (gcnew System::Windows::Forms::Label());
				 this->label23 = (gcnew System::Windows::Forms::Label());
				 this->groupBox2 = (gcnew System::Windows::Forms::GroupBox());
				 this->button18 = (gcnew System::Windows::Forms::Button());
				 this->dateTimePicker3 = (gcnew System::Windows::Forms::DateTimePicker());
				 this->button7 = (gcnew System::Windows::Forms::Button());
				 this->label21 = (gcnew System::Windows::Forms::Label());
				 this->dateTimePicker4 = (gcnew System::Windows::Forms::DateTimePicker());
				 this->label22 = (gcnew System::Windows::Forms::Label());
				 this->label20 = (gcnew System::Windows::Forms::Label());
				 this->timer1 = (gcnew System::Windows::Forms::Timer(this->components));
				 this->Column1 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
				 this->Column12 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
				 this->Column13 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
				 this->Column4 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
				 this->Column11 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
				 this->Column2 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
				 this->Column3 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
				 this->tabControl1->SuspendLayout();
				 this->tabPage1->SuspendLayout();
				 this->tabPage2->SuspendLayout();
				 this->groupBox1->SuspendLayout();
				 (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->dataGridView1))->BeginInit();
				 this->tabPage3->SuspendLayout();
				 (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->dataGridView2))->BeginInit();
				 this->tabPage4->SuspendLayout();
				 (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->dataGridView3))->BeginInit();
				 this->groupBox2->SuspendLayout();
				 this->SuspendLayout();
				 // 
				 // label1
				 // 
				 this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei", 20.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
					 static_cast<System::Byte>(134)));
				 this->label1->Location = System::Drawing::Point(118, 40);
				 this->label1->Name = L"label1";
				 this->label1->Size = System::Drawing::Size(350, 36);
				 this->label1->TabIndex = 0;
				 this->label1->Text = L"label1";
				 this->label1->TextAlign = System::Drawing::ContentAlignment::MiddleCenter;
				 // 
				 // tabControl1
				 // 
				 this->tabControl1->Controls->Add(this->tabPage1);
				 this->tabControl1->Controls->Add(this->tabPage2);
				 this->tabControl1->Controls->Add(this->tabPage3);
				 this->tabControl1->Controls->Add(this->tabPage4);
				 this->tabControl1->Font = (gcnew System::Drawing::Font(L"Nirmala UI", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
					 static_cast<System::Byte>(0)));
				 this->tabControl1->Location = System::Drawing::Point(65, 11);
				 this->tabControl1->Name = L"tabControl1";
				 this->tabControl1->SelectedIndex = 0;
				 this->tabControl1->Size = System::Drawing::Size(595, 677);
				 this->tabControl1->TabIndex = 1;
				 // 
				 // tabPage1
				 // 
				 this->tabPage1->Controls->Add(this->button2);
				 this->tabPage1->Controls->Add(this->label11);
				 this->tabPage1->Controls->Add(this->label10);
				 this->tabPage1->Controls->Add(this->label9);
				 this->tabPage1->Controls->Add(this->label8);
				 this->tabPage1->Controls->Add(this->button1);
				 this->tabPage1->Controls->Add(this->label6);
				 this->tabPage1->Controls->Add(this->label5);
				 this->tabPage1->Controls->Add(this->label3);
				 this->tabPage1->Controls->Add(this->label2);
				 this->tabPage1->Controls->Add(this->label1);
				 this->tabPage1->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
					 static_cast<System::Byte>(134)));
				 this->tabPage1->Location = System::Drawing::Point(4, 30);
				 this->tabPage1->Name = L"tabPage1";
				 this->tabPage1->Padding = System::Windows::Forms::Padding(3);
				 this->tabPage1->Size = System::Drawing::Size(587, 643);
				 this->tabPage1->TabIndex = 0;
				 this->tabPage1->Text = L"Home";
				 this->tabPage1->UseVisualStyleBackColor = true;
				 this->tabPage1->Enter += gcnew System::EventHandler(this, &MainWindow::tabPage1_Enter);
				 // 
				 // button2
				 // 
				 this->button2->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
					 static_cast<System::Byte>(134)));
				 this->button2->Location = System::Drawing::Point(171, 392);
				 this->button2->Name = L"button2";
				 this->button2->Size = System::Drawing::Size(75, 23);
				 this->button2->TabIndex = 13;
				 this->button2->Text = L"Today:";
				 this->button2->UseVisualStyleBackColor = true;
				 this->button2->Click += gcnew System::EventHandler(this, &MainWindow::button2_Click);
				 // 
				 // label11
				 // 
				 this->label11->AutoSize = true;
				 this->label11->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
					 static_cast<System::Byte>(134)));
				 this->label11->Location = System::Drawing::Point(365, 427);
				 this->label11->Name = L"label11";
				 this->label11->Size = System::Drawing::Size(53, 19);
				 this->label11->TabIndex = 11;
				 this->label11->Text = L"label11";
				 // 
				 // label10
				 // 
				 this->label10->AutoSize = true;
				 this->label10->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
					 static_cast<System::Byte>(134)));
				 this->label10->Location = System::Drawing::Point(365, 382);
				 this->label10->Name = L"label10";
				 this->label10->Size = System::Drawing::Size(53, 19);
				 this->label10->TabIndex = 10;
				 this->label10->Text = L"label10";
				 // 
				 // label9
				 // 
				 this->label9->AutoSize = true;
				 this->label9->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
					 static_cast<System::Byte>(134)));
				 this->label9->Location = System::Drawing::Point(283, 427);
				 this->label9->Name = L"label9";
				 this->label9->Size = System::Drawing::Size(58, 19);
				 this->label9->TabIndex = 9;
				 this->label9->Text = L"Income:";
				 // 
				 // label8
				 // 
				 this->label8->AutoSize = true;
				 this->label8->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
					 static_cast<System::Byte>(134)));
				 this->label8->Location = System::Drawing::Point(283, 382);
				 this->label8->Name = L"label8";
				 this->label8->Size = System::Drawing::Size(62, 19);
				 this->label8->TabIndex = 8;
				 this->label8->Text = L"Expense:";
				 // 
				 // button1
				 // 
				 this->button1->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei", 12));
				 this->button1->Location = System::Drawing::Point(179, 240);
				 this->button1->Name = L"button1";
				 this->button1->Size = System::Drawing::Size(229, 94);
				 this->button1->TabIndex = 7;
				 this->button1->Text = L"Add Transaction";
				 this->button1->UseVisualStyleBackColor = true;
				 this->button1->Click += gcnew System::EventHandler(this, &MainWindow::button1_Click);
				 // 
				 // label6
				 // 
				 this->label6->AutoSize = true;
				 this->label6->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
					 static_cast<System::Byte>(134)));
				 this->label6->Location = System::Drawing::Point(346, 167);
				 this->label6->Name = L"label6";
				 this->label6->Size = System::Drawing::Size(45, 19);
				 this->label6->TabIndex = 5;
				 this->label6->Text = L"label6";
				 // 
				 // label5
				 // 
				 this->label5->AutoSize = true;
				 this->label5->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
					 static_cast<System::Byte>(134)));
				 this->label5->Location = System::Drawing::Point(346, 134);
				 this->label5->Name = L"label5";
				 this->label5->Size = System::Drawing::Size(45, 19);
				 this->label5->TabIndex = 4;
				 this->label5->Text = L"label5";
				 // 
				 // label3
				 // 
				 this->label3->AutoSize = true;
				 this->label3->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
					 static_cast<System::Byte>(134)));
				 this->label3->Location = System::Drawing::Point(195, 167);
				 this->label3->Name = L"label3";
				 this->label3->Size = System::Drawing::Size(114, 19);
				 this->label3->TabIndex = 2;
				 this->label3->Text = L"Monthly Income:";
				 // 
				 // label2
				 // 
				 this->label2->AutoSize = true;
				 this->label2->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
					 static_cast<System::Byte>(134)));
				 this->label2->Location = System::Drawing::Point(195, 134);
				 this->label2->Name = L"label2";
				 this->label2->Size = System::Drawing::Size(118, 19);
				 this->label2->TabIndex = 1;
				 this->label2->Text = L"Monthly Expense:";
				 // 
				 // tabPage2
				 // 
				 this->tabPage2->Controls->Add(this->label32);
				 this->tabPage2->Controls->Add(this->button16);
				 this->tabPage2->Controls->Add(this->button15);
				 this->tabPage2->Controls->Add(this->button14);
				 this->tabPage2->Controls->Add(this->button13);
				 this->tabPage2->Controls->Add(this->groupBox1);
				 this->tabPage2->Controls->Add(this->dataGridView1);
				 this->tabPage2->Controls->Add(this->label12);
				 this->tabPage2->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
					 static_cast<System::Byte>(0)));
				 this->tabPage2->Location = System::Drawing::Point(4, 30);
				 this->tabPage2->Name = L"tabPage2";
				 this->tabPage2->Padding = System::Windows::Forms::Padding(3);
				 this->tabPage2->Size = System::Drawing::Size(587, 643);
				 this->tabPage2->TabIndex = 1;
				 this->tabPage2->Text = L"History";
				 this->tabPage2->UseVisualStyleBackColor = true;
				 this->tabPage2->Enter += gcnew System::EventHandler(this, &MainWindow::tabPage2_Enter);
				 // 
				 // label32
				 // 
				 this->label32->AutoSize = true;
				 this->label32->ImageAlign = System::Drawing::ContentAlignment::MiddleRight;
				 this->label32->Location = System::Drawing::Point(177, 612);
				 this->label32->Name = L"label32";
				 this->label32->Size = System::Drawing::Size(45, 16);
				 this->label32->TabIndex = 16;
				 this->label32->Text = L"label32";
				 // 
				 // button16
				 // 
				 this->button16->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
					 static_cast<System::Byte>(0)));
				 this->button16->Location = System::Drawing::Point(149, 589);
				 this->button16->Name = L"button16";
				 this->button16->Size = System::Drawing::Size(100, 23);
				 this->button16->TabIndex = 15;
				 this->button16->Text = L"Undo";
				 this->button16->UseVisualStyleBackColor = true;
				 this->button16->Click += gcnew System::EventHandler(this, &MainWindow::button16_Click);
				 // 
				 // button15
				 // 
				 this->button15->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
					 static_cast<System::Byte>(0)));
				 this->button15->Location = System::Drawing::Point(49, 589);
				 this->button15->Name = L"button15";
				 this->button15->Size = System::Drawing::Size(100, 23);
				 this->button15->TabIndex = 14;
				 this->button15->Text = L"Add";
				 this->button15->UseVisualStyleBackColor = true;
				 this->button15->Click += gcnew System::EventHandler(this, &MainWindow::button15_Click);
				 // 
				 // button14
				 // 
				 this->button14->Font = (gcnew System::Drawing::Font(L"Nirmala UI", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
					 static_cast<System::Byte>(0)));
				 this->button14->Location = System::Drawing::Point(337, 588);
				 this->button14->Name = L"button14";
				 this->button14->Size = System::Drawing::Size(100, 25);
				 this->button14->TabIndex = 13;
				 this->button14->Text = L"Edit";
				 this->button14->UseVisualStyleBackColor = true;
				 this->button14->Click += gcnew System::EventHandler(this, &MainWindow::button14_Click);
				 // 
				 // button13
				 // 
				 this->button13->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
					 static_cast<System::Byte>(0)));
				 this->button13->Location = System::Drawing::Point(437, 588);
				 this->button13->Name = L"button13";
				 this->button13->Size = System::Drawing::Size(100, 25);
				 this->button13->TabIndex = 12;
				 this->button13->Text = L"Delete";
				 this->button13->UseVisualStyleBackColor = true;
				 this->button13->Click += gcnew System::EventHandler(this, &MainWindow::button13_Click);
				 // 
				 // groupBox1
				 // 
				 this->groupBox1->Controls->Add(this->button17);
				 this->groupBox1->Controls->Add(this->label13);
				 this->groupBox1->Controls->Add(this->label16);
				 this->groupBox1->Controls->Add(this->dateTimePicker1);
				 this->groupBox1->Controls->Add(this->dateTimePicker2);
				 this->groupBox1->Controls->Add(this->button3);
				 this->groupBox1->Controls->Add(this->label14);
				 this->groupBox1->Controls->Add(this->comboBox2);
				 this->groupBox1->Controls->Add(this->label15);
				 this->groupBox1->Controls->Add(this->comboBox1);
				 this->groupBox1->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
					 static_cast<System::Byte>(134)));
				 this->groupBox1->Location = System::Drawing::Point(43, 76);
				 this->groupBox1->Name = L"groupBox1";
				 this->groupBox1->Size = System::Drawing::Size(500, 180);
				 this->groupBox1->TabIndex = 11;
				 this->groupBox1->TabStop = false;
				 this->groupBox1->Text = L"Search";
				 // 
				 // button17
				 // 
				 this->button17->Location = System::Drawing::Point(370, 136);
				 this->button17->Name = L"button17";
				 this->button17->Size = System::Drawing::Size(108, 25);
				 this->button17->TabIndex = 17;
				 this->button17->Text = L"Export to Excel";
				 this->button17->UseVisualStyleBackColor = true;
				 this->button17->Click += gcnew System::EventHandler(this, &MainWindow::button17_Click);
				 // 
				 // label13
				 // 
				 this->label13->AutoSize = true;
				 this->label13->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
					 static_cast<System::Byte>(134)));
				 this->label13->Location = System::Drawing::Point(22, 25);
				 this->label13->Name = L"label13";
				 this->label13->Size = System::Drawing::Size(71, 17);
				 this->label13->TabIndex = 2;
				 this->label13->Text = L"From date:";
				 // 
				 // label16
				 // 
				 this->label16->AutoSize = true;
				 this->label16->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
					 static_cast<System::Byte>(134)));
				 this->label16->Location = System::Drawing::Point(21, 140);
				 this->label16->Name = L"label16";
				 this->label16->Size = System::Drawing::Size(64, 17);
				 this->label16->TabIndex = 10;
				 this->label16->Text = L"Category:";
				 // 
				 // dateTimePicker1
				 // 
				 this->dateTimePicker1->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
					 static_cast<System::Byte>(134)));
				 this->dateTimePicker1->Location = System::Drawing::Point(22, 53);
				 this->dateTimePicker1->Name = L"dateTimePicker1";
				 this->dateTimePicker1->Size = System::Drawing::Size(200, 23);
				 this->dateTimePicker1->TabIndex = 0;
				 // 
				 // dateTimePicker2
				 // 
				 this->dateTimePicker2->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
					 static_cast<System::Byte>(134)));
				 this->dateTimePicker2->Location = System::Drawing::Point(278, 53);
				 this->dateTimePicker2->Name = L"dateTimePicker2";
				 this->dateTimePicker2->Size = System::Drawing::Size(200, 23);
				 this->dateTimePicker2->TabIndex = 3;
				 // 
				 // button3
				 // 
				 this->button3->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
					 static_cast<System::Byte>(134)));
				 this->button3->Location = System::Drawing::Point(403, 95);
				 this->button3->Name = L"button3";
				 this->button3->Size = System::Drawing::Size(75, 25);
				 this->button3->TabIndex = 8;
				 this->button3->Text = L"Refresh";
				 this->button3->UseVisualStyleBackColor = true;
				 this->button3->Click += gcnew System::EventHandler(this, &MainWindow::button3_Click);
				 // 
				 // label14
				 // 
				 this->label14->AutoSize = true;
				 this->label14->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
					 static_cast<System::Byte>(134)));
				 this->label14->Location = System::Drawing::Point(278, 25);
				 this->label14->Name = L"label14";
				 this->label14->Size = System::Drawing::Size(56, 17);
				 this->label14->TabIndex = 4;
				 this->label14->Text = L"To date:";
				 // 
				 // comboBox2
				 // 
				 this->comboBox2->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
				 this->comboBox2->FormattingEnabled = true;
				 this->comboBox2->Location = System::Drawing::Point(88, 136);
				 this->comboBox2->Name = L"comboBox2";
				 this->comboBox2->Size = System::Drawing::Size(121, 25);
				 this->comboBox2->TabIndex = 7;
				 // 
				 // label15
				 // 
				 this->label15->AutoSize = true;
				 this->label15->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
					 static_cast<System::Byte>(134)));
				 this->label15->Location = System::Drawing::Point(21, 99);
				 this->label15->Name = L"label15";
				 this->label15->Size = System::Drawing::Size(57, 17);
				 this->label15->TabIndex = 5;
				 this->label15->Text = L"Account:";
				 // 
				 // comboBox1
				 // 
				 this->comboBox1->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
				 this->comboBox1->FormattingEnabled = true;
				 this->comboBox1->Location = System::Drawing::Point(88, 95);
				 this->comboBox1->Name = L"comboBox1";
				 this->comboBox1->Size = System::Drawing::Size(121, 25);
				 this->comboBox1->TabIndex = 6;
				 // 
				 // dataGridView1
				 // 
				 this->dataGridView1->AllowUserToAddRows = false;
				 this->dataGridView1->AllowUserToDeleteRows = false;
				 this->dataGridView1->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
				 this->dataGridView1->Columns->AddRange(gcnew cli::array< System::Windows::Forms::DataGridViewColumn^  >(7) {this->Column1, 
					 this->Column12, this->Column13, this->Column4, this->Column11, this->Column2, this->Column3});
				 this->dataGridView1->Location = System::Drawing::Point(44, 278);
				 this->dataGridView1->Name = L"dataGridView1";
				 this->dataGridView1->ReadOnly = true;
				 this->dataGridView1->RowHeadersVisible = false;
				 this->dataGridView1->RowTemplate->Height = 23;
				 this->dataGridView1->SelectionMode = System::Windows::Forms::DataGridViewSelectionMode::FullRowSelect;
				 this->dataGridView1->Size = System::Drawing::Size(499, 280);
				 this->dataGridView1->TabIndex = 9;
				 // 
				 // label12
				 // 
				 this->label12->AutoSize = true;
				 this->label12->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei", 20.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
					 static_cast<System::Byte>(134)));
				 this->label12->Location = System::Drawing::Point(152, 40);
				 this->label12->Name = L"label12";
				 this->label12->Size = System::Drawing::Size(282, 36);
				 this->label12->TabIndex = 1;
				 this->label12->Text = L"Transaction History";
				 this->label12->TextAlign = System::Drawing::ContentAlignment::MiddleCenter;
				 // 
				 // tabPage3
				 // 
				 this->tabPage3->BackColor = System::Drawing::Color::White;
				 this->tabPage3->Controls->Add(this->button10);
				 this->tabPage3->Controls->Add(this->dataGridView2);
				 this->tabPage3->Controls->Add(this->button5);
				 this->tabPage3->Controls->Add(this->button4);
				 this->tabPage3->Controls->Add(this->label19);
				 this->tabPage3->Controls->Add(this->label18);
				 this->tabPage3->Controls->Add(this->label17);
				 this->tabPage3->Location = System::Drawing::Point(4, 30);
				 this->tabPage3->Name = L"tabPage3";
				 this->tabPage3->Padding = System::Windows::Forms::Padding(3);
				 this->tabPage3->Size = System::Drawing::Size(587, 643);
				 this->tabPage3->TabIndex = 2;
				 this->tabPage3->Text = L"Account";
				 this->tabPage3->Enter += gcnew System::EventHandler(this, &MainWindow::tabPage3_Enter);
				 // 
				 // button10
				 // 
				 this->button10->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
					 static_cast<System::Byte>(134)));
				 this->button10->Location = System::Drawing::Point(350, 442);
				 this->button10->Name = L"button10";
				 this->button10->Size = System::Drawing::Size(100, 25);
				 this->button10->TabIndex = 7;
				 this->button10->Text = L"Delete";
				 this->button10->UseVisualStyleBackColor = true;
				 this->button10->Click += gcnew System::EventHandler(this, &MainWindow::button10_Click);
				 // 
				 // dataGridView2
				 // 
				 this->dataGridView2->AllowUserToAddRows = false;
				 this->dataGridView2->AllowUserToDeleteRows = false;
				 this->dataGridView2->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
				 this->dataGridView2->Columns->AddRange(gcnew cli::array< System::Windows::Forms::DataGridViewColumn^  >(3) {this->Column5, 
					 this->Column6, this->Column7});
				 this->dataGridView2->Location = System::Drawing::Point(129, 151);
				 this->dataGridView2->Name = L"dataGridView2";
				 this->dataGridView2->ReadOnly = true;
				 this->dataGridView2->RowHeadersVisible = false;
				 this->dataGridView2->RowTemplate->Height = 23;
				 this->dataGridView2->SelectionMode = System::Windows::Forms::DataGridViewSelectionMode::FullRowSelect;
				 this->dataGridView2->Size = System::Drawing::Size(328, 227);
				 this->dataGridView2->TabIndex = 6;
				 // 
				 // Column5
				 // 
				 this->Column5->Frozen = true;
				 this->Column5->HeaderText = L"Name";
				 this->Column5->Name = L"Column5";
				 this->Column5->ReadOnly = true;
				 this->Column5->Width = 150;
				 // 
				 // Column6
				 // 
				 this->Column6->HeaderText = L"Balance";
				 this->Column6->Name = L"Column6";
				 this->Column6->ReadOnly = true;
				 // 
				 // Column7
				 // 
				 this->Column7->HeaderText = L"";
				 this->Column7->Name = L"Column7";
				 this->Column7->ReadOnly = true;
				 this->Column7->Width = 30;
				 // 
				 // button5
				 // 
				 this->button5->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
					 static_cast<System::Byte>(0)));
				 this->button5->Location = System::Drawing::Point(350, 411);
				 this->button5->Name = L"button5";
				 this->button5->Size = System::Drawing::Size(100, 25);
				 this->button5->TabIndex = 4;
				 this->button5->Text = L"Edit Name";
				 this->button5->UseVisualStyleBackColor = true;
				 this->button5->Click += gcnew System::EventHandler(this, &MainWindow::button5_Click);
				 // 
				 // button4
				 // 
				 this->button4->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
					 static_cast<System::Byte>(0)));
				 this->button4->Location = System::Drawing::Point(136, 411);
				 this->button4->Name = L"button4";
				 this->button4->Size = System::Drawing::Size(100, 25);
				 this->button4->TabIndex = 3;
				 this->button4->Text = L"Create";
				 this->button4->UseVisualStyleBackColor = true;
				 this->button4->Click += gcnew System::EventHandler(this, &MainWindow::button4_Click);
				 // 
				 // label19
				 // 
				 this->label19->AutoSize = true;
				 this->label19->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
					 static_cast<System::Byte>(134)));
				 this->label19->Location = System::Drawing::Point(336, 112);
				 this->label19->Name = L"label19";
				 this->label19->Size = System::Drawing::Size(53, 19);
				 this->label19->TabIndex = 2;
				 this->label19->Text = L"label19";
				 // 
				 // label18
				 // 
				 this->label18->AutoSize = true;
				 this->label18->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
					 static_cast<System::Byte>(134)));
				 this->label18->Location = System::Drawing::Point(201, 112);
				 this->label18->Name = L"label18";
				 this->label18->Size = System::Drawing::Size(93, 19);
				 this->label18->TabIndex = 1;
				 this->label18->Text = L"Total Balance:";
				 // 
				 // label17
				 // 
				 this->label17->AutoSize = true;
				 this->label17->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei", 20.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
					 static_cast<System::Byte>(134)));
				 this->label17->Location = System::Drawing::Point(229, 40);
				 this->label17->Name = L"label17";
				 this->label17->Size = System::Drawing::Size(128, 36);
				 this->label17->TabIndex = 0;
				 this->label17->Text = L"Account";
				 this->label17->TextAlign = System::Drawing::ContentAlignment::MiddleCenter;
				 // 
				 // tabPage4
				 // 
				 this->tabPage4->Controls->Add(this->button9);
				 this->tabPage4->Controls->Add(this->button8);
				 this->tabPage4->Controls->Add(this->button6);
				 this->tabPage4->Controls->Add(this->dataGridView3);
				 this->tabPage4->Controls->Add(this->label24);
				 this->tabPage4->Controls->Add(this->label23);
				 this->tabPage4->Controls->Add(this->groupBox2);
				 this->tabPage4->Controls->Add(this->label20);
				 this->tabPage4->Location = System::Drawing::Point(4, 30);
				 this->tabPage4->Name = L"tabPage4";
				 this->tabPage4->Padding = System::Windows::Forms::Padding(3);
				 this->tabPage4->Size = System::Drawing::Size(587, 643);
				 this->tabPage4->TabIndex = 3;
				 this->tabPage4->Text = L"Expense Report";
				 this->tabPage4->UseVisualStyleBackColor = true;
				 this->tabPage4->Enter += gcnew System::EventHandler(this, &MainWindow::tabPage4_Enter);
				 // 
				 // button9
				 // 
				 this->button9->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
					 static_cast<System::Byte>(134)));
				 this->button9->Location = System::Drawing::Point(374, 569);
				 this->button9->Name = L"button9";
				 this->button9->Size = System::Drawing::Size(100, 25);
				 this->button9->TabIndex = 12;
				 this->button9->Text = L"Delete";
				 this->button9->UseVisualStyleBackColor = true;
				 this->button9->Click += gcnew System::EventHandler(this, &MainWindow::button9_Click);
				 // 
				 // button8
				 // 
				 this->button8->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
					 static_cast<System::Byte>(134)));
				 this->button8->Location = System::Drawing::Point(374, 538);
				 this->button8->Name = L"button8";
				 this->button8->Size = System::Drawing::Size(100, 25);
				 this->button8->TabIndex = 11;
				 this->button8->Text = L"Edit Name";
				 this->button8->UseVisualStyleBackColor = true;
				 this->button8->Click += gcnew System::EventHandler(this, &MainWindow::button8_Click);
				 // 
				 // button6
				 // 
				 this->button6->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
					 static_cast<System::Byte>(134)));
				 this->button6->Location = System::Drawing::Point(114, 538);
				 this->button6->Name = L"button6";
				 this->button6->Size = System::Drawing::Size(100, 25);
				 this->button6->TabIndex = 10;
				 this->button6->Text = L"Create Category";
				 this->button6->UseVisualStyleBackColor = true;
				 this->button6->Click += gcnew System::EventHandler(this, &MainWindow::button6_Click);
				 // 
				 // dataGridView3
				 // 
				 this->dataGridView3->AllowUserToAddRows = false;
				 this->dataGridView3->AllowUserToDeleteRows = false;
				 this->dataGridView3->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
				 this->dataGridView3->Columns->AddRange(gcnew cli::array< System::Windows::Forms::DataGridViewColumn^  >(3) {this->Column8, 
					 this->Column9, this->Column10});
				 this->dataGridView3->Location = System::Drawing::Point(106, 285);
				 this->dataGridView3->Name = L"dataGridView3";
				 this->dataGridView3->ReadOnly = true;
				 this->dataGridView3->RowHeadersVisible = false;
				 this->dataGridView3->RowTemplate->Height = 23;
				 this->dataGridView3->SelectionMode = System::Windows::Forms::DataGridViewSelectionMode::FullRowSelect;
				 this->dataGridView3->Size = System::Drawing::Size(375, 222);
				 this->dataGridView3->TabIndex = 9;
				 // 
				 // Column8
				 // 
				 this->Column8->Frozen = true;
				 this->Column8->HeaderText = L"Category";
				 this->Column8->Name = L"Column8";
				 this->Column8->ReadOnly = true;
				 // 
				 // Column9
				 // 
				 this->Column9->HeaderText = L"Amount";
				 this->Column9->Name = L"Column9";
				 this->Column9->ReadOnly = true;
				 // 
				 // Column10
				 // 
				 this->Column10->HeaderText = L"%Total";
				 this->Column10->Name = L"Column10";
				 this->Column10->ReadOnly = true;
				 // 
				 // label24
				 // 
				 this->label24->AutoSize = true;
				 this->label24->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
					 static_cast<System::Byte>(134)));
				 this->label24->Location = System::Drawing::Point(320, 254);
				 this->label24->Name = L"label24";
				 this->label24->Size = System::Drawing::Size(53, 19);
				 this->label24->TabIndex = 8;
				 this->label24->Text = L"label24";
				 // 
				 // label23
				 // 
				 this->label23->AutoSize = true;
				 this->label23->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
					 static_cast<System::Byte>(134)));
				 this->label23->Location = System::Drawing::Point(216, 254);
				 this->label23->Name = L"label23";
				 this->label23->Size = System::Drawing::Size(96, 19);
				 this->label23->TabIndex = 7;
				 this->label23->Text = L"Total Expense:";
				 // 
				 // groupBox2
				 // 
				 this->groupBox2->Controls->Add(this->button18);
				 this->groupBox2->Controls->Add(this->dateTimePicker3);
				 this->groupBox2->Controls->Add(this->button7);
				 this->groupBox2->Controls->Add(this->label21);
				 this->groupBox2->Controls->Add(this->dateTimePicker4);
				 this->groupBox2->Controls->Add(this->label22);
				 this->groupBox2->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
					 static_cast<System::Byte>(134)));
				 this->groupBox2->Location = System::Drawing::Point(43, 91);
				 this->groupBox2->Name = L"groupBox2";
				 this->groupBox2->Size = System::Drawing::Size(500, 142);
				 this->groupBox2->TabIndex = 6;
				 this->groupBox2->TabStop = false;
				 this->groupBox2->Text = L"Search";
				 // 
				 // button18
				 // 
				 this->button18->Location = System::Drawing::Point(278, 94);
				 this->button18->Name = L"button18";
				 this->button18->Size = System::Drawing::Size(105, 25);
				 this->button18->TabIndex = 6;
				 this->button18->Text = L"Export to Excel";
				 this->button18->UseVisualStyleBackColor = true;
				 this->button18->Click += gcnew System::EventHandler(this, &MainWindow::button18_Click);
				 // 
				 // dateTimePicker3
				 // 
				 this->dateTimePicker3->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
					 static_cast<System::Byte>(134)));
				 this->dateTimePicker3->Location = System::Drawing::Point(22, 48);
				 this->dateTimePicker3->Name = L"dateTimePicker3";
				 this->dateTimePicker3->Size = System::Drawing::Size(200, 23);
				 this->dateTimePicker3->TabIndex = 2;
				 // 
				 // button7
				 // 
				 this->button7->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
					 static_cast<System::Byte>(134)));
				 this->button7->Location = System::Drawing::Point(391, 94);
				 this->button7->Name = L"button7";
				 this->button7->Size = System::Drawing::Size(75, 25);
				 this->button7->TabIndex = 5;
				 this->button7->Text = L"Refresh";
				 this->button7->UseVisualStyleBackColor = true;
				 this->button7->Click += gcnew System::EventHandler(this, &MainWindow::button7_Click);
				 // 
				 // label21
				 // 
				 this->label21->AutoSize = true;
				 this->label21->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
					 static_cast<System::Byte>(134)));
				 this->label21->Location = System::Drawing::Point(22, 20);
				 this->label21->Name = L"label21";
				 this->label21->Size = System::Drawing::Size(71, 17);
				 this->label21->TabIndex = 1;
				 this->label21->Text = L"From date:";
				 // 
				 // dateTimePicker4
				 // 
				 this->dateTimePicker4->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
					 static_cast<System::Byte>(134)));
				 this->dateTimePicker4->Location = System::Drawing::Point(278, 48);
				 this->dateTimePicker4->Name = L"dateTimePicker4";
				 this->dateTimePicker4->Size = System::Drawing::Size(200, 23);
				 this->dateTimePicker4->TabIndex = 4;
				 // 
				 // label22
				 // 
				 this->label22->AutoSize = true;
				 this->label22->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
					 static_cast<System::Byte>(134)));
				 this->label22->Location = System::Drawing::Point(278, 20);
				 this->label22->Name = L"label22";
				 this->label22->Size = System::Drawing::Size(56, 17);
				 this->label22->TabIndex = 3;
				 this->label22->Text = L"To date:";
				 // 
				 // label20
				 // 
				 this->label20->AutoSize = true;
				 this->label20->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei", 20.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
					 static_cast<System::Byte>(134)));
				 this->label20->Location = System::Drawing::Point(179, 40);
				 this->label20->Name = L"label20";
				 this->label20->Size = System::Drawing::Size(228, 36);
				 this->label20->TabIndex = 0;
				 this->label20->Text = L"Expense Report";
				 this->label20->TextAlign = System::Drawing::ContentAlignment::MiddleCenter;
				 // 
				 // timer1
				 // 
				 this->timer1->Enabled = true;
				 this->timer1->Interval = 1000;
				 this->timer1->Tick += gcnew System::EventHandler(this, &MainWindow::timer1_Tick);
				 // 
				 // Column1
				 // 
				 this->Column1->Frozen = true;
				 this->Column1->HeaderText = L"SN";
				 this->Column1->Name = L"Column1";
				 this->Column1->ReadOnly = true;
				 this->Column1->Visible = false;
				 this->Column1->Width = 50;
				 // 
				 // Column12
				 // 
				 this->Column12->HeaderText = L"Date";
				 this->Column12->Name = L"Column12";
				 this->Column12->ReadOnly = true;
				 this->Column12->Width = 90;
				 // 
				 // Column13
				 // 
				 this->Column13->HeaderText = L"Time";
				 this->Column13->Name = L"Column13";
				 this->Column13->ReadOnly = true;
				 this->Column13->Width = 70;
				 // 
				 // Column4
				 // 
				 this->Column4->HeaderText = L"Category";
				 this->Column4->Name = L"Column4";
				 this->Column4->ReadOnly = true;
				 // 
				 // Column11
				 // 
				 this->Column11->HeaderText = L"Amount";
				 this->Column11->Name = L"Column11";
				 this->Column11->ReadOnly = true;
				 // 
				 // Column2
				 // 
				 this->Column2->HeaderText = L"From";
				 this->Column2->Name = L"Column2";
				 this->Column2->ReadOnly = true;
				 this->Column2->Width = 70;
				 // 
				 // Column3
				 // 
				 this->Column3->HeaderText = L"To";
				 this->Column3->Name = L"Column3";
				 this->Column3->ReadOnly = true;
				 this->Column3->Width = 70;
				 // 
				 // MainWindow
				 // 
				 this->AutoScaleDimensions = System::Drawing::SizeF(6, 12);
				 this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
				 this->ClientSize = System::Drawing::Size(724, 711);
				 this->Controls->Add(this->tabControl1);
				 this->Icon = (cli::safe_cast<System::Drawing::Icon^  >(resources->GetObject(L"$this.Icon")));
				 this->Name = L"MainWindow";
				 this->Text = L"EzXpns";
				 this->Activated += gcnew System::EventHandler(this, &MainWindow::MainWindow_Activated);
				 this->FormClosing += gcnew System::Windows::Forms::FormClosingEventHandler(this, &MainWindow::MainWindow_FormClosing);
				 this->Load += gcnew System::EventHandler(this, &MainWindow::MainWindow_Load);
				 this->tabControl1->ResumeLayout(false);
				 this->tabPage1->ResumeLayout(false);
				 this->tabPage1->PerformLayout();
				 this->tabPage2->ResumeLayout(false);
				 this->tabPage2->PerformLayout();
				 this->groupBox1->ResumeLayout(false);
				 this->groupBox1->PerformLayout();
				 (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->dataGridView1))->EndInit();
				 this->tabPage3->ResumeLayout(false);
				 this->tabPage3->PerformLayout();
				 (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->dataGridView2))->EndInit();
				 this->tabPage4->ResumeLayout(false);
				 this->tabPage4->PerformLayout();
				 (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->dataGridView3))->EndInit();
				 this->groupBox2->ResumeLayout(false);
				 this->groupBox2->PerformLayout();
				 this->ResumeLayout(false);

			 }

#pragma endregion

			 //@author A0091791X
	private: System::Void MainWindow_Load(System::Object^  sender, System::EventArgs^  e) {
			 }
	private: System::Void MainWindow_FormClosing(System::Object^  sender, System::Windows::Forms::FormClosingEventArgs^  e) {
				 updateALL("<>?");
			 }
	private: System::Void MainWindow_Activated(System::Object^  sender, System::EventArgs^  e) {
				 refreshHome();
				 refreshHistory();
				 refreshAccount();
				 refreshExpRep();
			 }
			 //Timer
	private: System::Void timer1_Tick(System::Object^  sender, System::EventArgs^  e) {
				 label1->Text = sysTime();
			 }

	private: System::Void tabPage1_Enter(System::Object^  sender, System::EventArgs^  e) {
				 refreshHome();
			 }
	private: System::Void tabPage2_Enter(System::Object^  sender, System::EventArgs^  e) {
				 if(TM->getActionStackSize()==0)
					 button16->Enabled=false;
				 else
					 button16->Enabled=true;
				 if(dataGridView1->Rows->Count == 0)
				 {
					 button13->Enabled=false;
					 button14->Enabled=false;
				 }
				 else
				 {
					 button13->Enabled=true;
					 button14->Enabled=true;
				 }
				 label32->Text=System::Convert::ToString(TM->getActionStackSize());
				 FillTransHist(dataGridView1);
			 }
	private: System::Void tabPage3_Enter(System::Object^  sender, System::EventArgs^  e) {
				 refreshAccount();
			 }
	private: System::Void tabPage4_Enter(System::Object^  sender, System::EventArgs^  e) {
				 refreshExpRep();
			 }

			 //Add/Edit/Delete Transaction
	private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
				 AddTransaction^ addTrans = gcnew AddTransaction;
				 addTrans->Show();
			 }
	private: System::Void button15_Click(System::Object^  sender, System::EventArgs^  e) {
				 AddTransaction^ addTrans = gcnew AddTransaction;
				 addTrans->Show();
			 }
	private: System::Void button14_Click(System::Object^  sender, System::EventArgs^  e) {
				 int SN;
				 if(dataGridView1->Rows->Count == 0)
				 {
					 MessageBox::Show("No Transaction is selected");
					 return;
				 }
				 int tempIdx;
				 tempIdx = dataGridView1->CurrentRow->Index;
				 SN = System::Convert::ToInt32(dataGridView1[0,tempIdx]->Value->ToString());
				 if(TM->findTransaction(SN)->getAccount()=="delete" 
					 || TM->findTransaction(SN)->getAccountFrom()=="delete" 
					 || TM->findTransaction(SN)->getAccountFrom()=="delete" )
				 {
					 MessageBox::Show("Transactions related to \"delete\" account cannot be modified");
					 return;
				 }
				 EditTransaction^ editTrans = gcnew EditTransaction(SN);
				 editTrans->Show();
			 }
	private: System::Void button13_Click(System::Object^  sender, System::EventArgs^  e) {
				 int SN;
				 if(dataGridView1->Rows->Count == 0)
				 {
					 MessageBox::Show("No Transaction is selected");
					 return;
				 }
				 int tempIdx;
				 tempIdx = dataGridView1->CurrentRow->Index;
				 SN = System::Convert::ToInt32(dataGridView1[0,tempIdx]->Value->ToString());

				 if(TM->findTransaction(SN)->getAccount()=="delete" 
					 || TM->findTransaction(SN)->getAccountFrom()=="delete" 
					 || TM->findTransaction(SN)->getAccountFrom()=="delete" )
				 {
					 MessageBox::Show("Transactions related to \"delete\" account cannot be modified");
					 return;
				 }

				 if(MessageBox::Show("Are you sure you want to delete this Transaction?",
					 "Confirmation", MessageBoxButtons::OKCancel)== System::Windows::Forms::DialogResult::OK)
				 {
					 if(TM->delTransaction(TM->findTransaction(SN)))
					 {
						 if(TM->getActionStackSize()==0)
							 button16->Enabled=false;
						 else
							 button16->Enabled=true;
						 if(dataGridView1->Rows->Count == 0)
						 {
							 button13->Enabled=false;
							 button14->Enabled=false;
						 }
						 else
						 {
							 button13->Enabled=true;
							 button14->Enabled=true;
						 }
						 label32->Text=System::Convert::ToString(TM->getActionStackSize());
						 FillTransHist(dataGridView1);
					 }
					 else
						 MessageBox::Show("Failed");
				 }
			 }

			 //Add/Edit/Delete Account
	private: System::Void button4_Click(System::Object^  sender, System::EventArgs^  e) {
				 AddAccount^ addAcc = gcnew AddAccount();
				 addAcc->Show();
			 }
	private: System::Void button5_Click(System::Object^  sender, System::EventArgs^  e) {
				 String^ AccName;
				 int tempIdx;
				 tempIdx = dataGridView2->CurrentRow->Index;
				 AccName = dataGridView2[0,tempIdx]->Value->ToString();
				 if(AccName=="Cash")
				 {
					 MessageBox::Show("\"Cash\" is predefined by EzXpns and cannot be edited.");
					 return;
				 }
				 EditAccountName^ editAccName = gcnew EditAccountName(AccName);
				 editAccName->Show();
			 }
	private: System::Void button10_Click(System::Object^  sender, System::EventArgs^  e) {
				 String^ acc;
				 int tempIdx;
				 tempIdx = dataGridView2->CurrentRow->Index;
				 acc = dataGridView2[0,tempIdx]->Value->ToString();

				 if(acc=="Cash")
				 {
					 MessageBox::Show("\"Cash\" is predefined by EzXpns and cannot be deleted.");
					 return;
				 }

				 if(MessageBox::Show("Are you sure you want to delete this Account?\nRemaining account balance will be transfered to \"Cash\".",
					 "Confirmation", MessageBoxButtons::OKCancel)== System::Windows::Forms::DialogResult::OK)
				 {
					 if(TM->delAccount(msclr::interop::marshal_as<std::string>(acc)))
					 {
						 TM->clearActionStack();
						 refreshAccount();
					 }
					 else
						 MessageBox::Show("Failed");
				 }
			 }

			 //Add/Edit/Delete Category
	private: System::Void button6_Click(System::Object^  sender, System::EventArgs^  e) {
				 AddCategory^ addCat = gcnew AddCategory();
				 addCat->Show();
			 }
	private: System::Void button8_Click(System::Object^  sender, System::EventArgs^  e) {
				 String^ CatName;
				 int tempIdx;
				 tempIdx = dataGridView3->CurrentRow->Index;
				 CatName = dataGridView3[0,tempIdx]->Value->ToString();
				 if(CatName=="Others")
				 {
					 MessageBox::Show("OTHERS is predefined by EzXpns and cannot be edited.");
					 return;
				 }
				 EditCategoryName^ editCatName = gcnew EditCategoryName(CatName);
				 editCatName->Show();
			 }
	private: System::Void button9_Click(System::Object^  sender, System::EventArgs^  e) {
				 String^ cat;
				 int tempIdx;
				 tempIdx = dataGridView3->CurrentRow->Index;
				 cat = dataGridView3[0,tempIdx]->Value->ToString();

				 if(cat=="Others")
				 {
					 MessageBox::Show("\"Others\" category is predefined by EzXpns and cannot be deleted.");
					 return;
				 }

				 if(MessageBox::Show("Are you sure you want to delete this category?\nAll the past transactions will be moved to \"Others\" Category.",
					 "Confirmation", MessageBoxButtons::OKCancel)== System::Windows::Forms::DialogResult::OK)
				 {
					 if(TM->delCategory(msclr::interop::marshal_as<std::string>(cat)))
					 {
						 TM->clearActionStack();
						 refreshExpRep();
					 }
					 else
						 MessageBox::Show("Failed");
				 }
			 }

			 //Refresh EXPENSE REPORT button
	private: System::Void button7_Click(System::Object^  sender, System::EventArgs^  e) {
				 refreshExpRep();
			 }
			 //Today button
	private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
				 tabControl1->SelectedTab = tabPage2;
				 dateTimePicker1->Value = DateTime::Today;
				 dateTimePicker2->Value = DateTime::Today;
				 button3->PerformClick();
			 }
			 //Refresh HISTORY button
	private: System::Void button3_Click(System::Object^  sender, System::EventArgs^  e) {
				 FillTransHist(dataGridView1);
			 }
			 //@author A0090982W
			 //Export Transaction History to Excel
	private: System::Void button17_Click(System::Object^  sender, System::EventArgs^  e) {
				 button3->PerformClick();
				 if(dataGridView1->Rows->Count==0)
				 {
					 MessageBox::Show("Search Result is empty");
					 return;
				 }
				 //1. Create a new Excel application
				 Excel::Application^ exApp = gcnew Excel::ApplicationClass();
				 //2. Add a workbook (comes with three Worksheets)
				 Excel::Workbook^   exWb  = exApp->Workbooks->Add(Type::Missing);
				 //3. Create a variable for the active Worksheet's tracking handle
				 //  (first Worksheet is the default active one)
				 Excel::Worksheet^  exWs  = safe_cast<Excel::Worksheet^>(exApp->ActiveSheet); 
				 //4. Rename the active worksheet
				 exWs->Name = "Transaction History"; 
				 //5. Load Title
				 exWs->Cells[1, 1] = "TRANSACTION HISTORY";
				 exWs->Cells[2, 1] = "From:";		exWs->Cells[2, 2] = dateTimePicker1->Value.ToString();
				 exWs->Cells[2, 3] = "To:";			exWs->Cells[2, 4] = dateTimePicker2->Value.ToString();
				 exWs->Cells[3, 1] = "Account:";	exWs->Cells[3, 2] = comboBox1->Text;
				 exWs->Cells[4, 1] = "Category:";	exWs->Cells[4, 2] = comboBox2->Text;

				 exWs->Cells[6, 1] = "Date";
				 exWs->Cells[6, 2] = "Time";
				 exWs->Cells[6, 3] = "Category";
				 exWs->Cells[6, 4] = "Amount";
				 exWs->Cells[6, 5] = "From Account";
				 exWs->Cells[6, 6] = "To Account";
				 //6. Load the data
				 int i=0, j=0; 
				 for (i = 6; i+1-6 <= dataGridView1->Rows->Count; i++)
					 for (j = 0; j+1 <= dataGridView1->Columns->Count-1; j++)
						 exWs->Cells[i+1, j+1] = dataGridView1[j+1, i-6]->Value;
				 exWs->Cells[i+2,1]="Total Expense:";	exWs->Cells[i+2,4]=toShow->getTotalExpense();
				 exWs->Cells[i+3,1]="Total Income:";		exWs->Cells[i+3,4]=toShow->getTotalIncome();
				 //7. Show the Workbook
				 exApp->Visible = true;
		 }
			 //Undo
	private: System::Void button16_Click(System::Object^  sender, System::EventArgs^  e) {
				 TM->performUndo();
				 if(TM->getActionStackSize()==0)
					 button16->Enabled=false;
				 else
					 button16->Enabled=true;
				 if(dataGridView1->Rows->Count == 0)
				 {
					 button13->Enabled=false;
					 button14->Enabled=false;
				 }
				 else
				 {
					 button13->Enabled=true;
					 button14->Enabled=true;
				 }
				 label32->Text=System::Convert::ToString(TM->getActionStackSize());
				 FillTransHist(dataGridView1);
			 }
			 //Export Expense Report to Excel
	private: System::Void button18_Click(System::Object^  sender, System::EventArgs^  e) {
				 button7->PerformClick();

				 //1. Create a new Excel application
				 Excel::Application^ exApp = gcnew Excel::ApplicationClass();
				 //2. Add a workbook (comes with three Worksheets)
				 Excel::Workbook^   exWb  = exApp->Workbooks->Add(Type::Missing);
				 //3. Create a variable for the active Worksheet's tracking handle
				 //  (first Worksheet is the default active one)
				 Excel::Worksheet^  exWs  = safe_cast<Excel::Worksheet^>(exApp->ActiveSheet); 
				 //4. Rename the active worksheet
				 exWs->Name = "Expense Report"; 
				 //5. Load Title
				 exWs->Cells[1, 1] = "EXPENSE REPORT";
				 exWs->Cells[2, 1] = "From:";		exWs->Cells[2, 2] = dateTimePicker3->Value.ToString();
				 exWs->Cells[2, 3] = "To:";			exWs->Cells[2, 4] = dateTimePicker4->Value.ToString();

				 exWs->Cells[4, 1] = "Category";
				 exWs->Cells[4, 2] = "Amount";

				 //6. Load the data
				 int i=0, j=0; 
				 for (i = 4; i+1-4 <= dataGridView3->Rows->Count; i++)
					 for (j = 0; j+1 <= dataGridView3->Columns->Count-1; j++)
						 exWs->Cells[i+1, j+1] = dataGridView3[j, i-4]->Value;
				 exWs->Cells[i+2,1]="Total Expense:";	exWs->Cells[i+2,2]=label24->Text;
				 //make bar chart
				 BarChart(exWs,dataGridView3->Rows->Count,3);
				 //7. Show the Workbook
				 exApp->Visible = true;
			 }
	private: void BarChart(Excel::Worksheet ^ws, int row, int col)
			 {
				 int         xPos = (col+2)*52;      //Col width 48 points. Chart starts in 3rd col
				 int         yPos = row*12;           //Row height = 9, Chart starts in 2nd row
				 //double      subTotal = 0;
				 //String^     time;
				 //1. Format to 2 decimal places for chart data
				 //ws->Range["B5", Type::Missing]->EntireColumn->NumberFormat = "#,##0.00";

				 //2. Set all Worksheet column widths to 12 to fit column titles and data
				 safe_cast<Excel::Range^>(ws->Columns)->ColumnWidth = 12;

				 //4. Create a ChartObjects Collection for the Worksheet
				 Excel::ChartObjects^ chObjs = safe_cast<Excel::ChartObjects^>(ws->ChartObjects(Type::Missing));

				 //5. Add a ChartObject to the collection at(x, y, width, height) in points
				 Excel::ChartObject^ chObj = chObjs->Add(xPos, yPos, 300, 300);

				 //6. Create a chart from the ChartObject
				 Excel::Chart^ ch = chObj->Chart;

				 //7. Create a Range object & set the data range.
				 Excel::Range^ rn = ws->Range[ws->Cells[5,1], ws->Cells[row+5,1]];

				 //8. Do the chart using ChartWizard
				 ch->ChartWizard(rn->CurrentRegion,      //Source
					 Excel::XlChartType::xlColumnClustered,//xlPie,         //Gallery
					 Type::Missing,                      //Format
					 Excel::XlRowCol::xlColumns,         //Plot by
					 1,                                  //Category Labels
					 Type::Missing,                      //Series Labels
					 false,                              //Has Legend
					 "Expense Report",                   //Title
					 "Category",                         //Category Title (X)
					 "Subtotal",                         //Value Title (Y)
					 Type::Missing);                     //Extra Title

				 //9. Format the x-axis of the Cargo graph
				 safe_cast<Excel::Axis^>(ch->Axes(Excel::XlAxisType::xlValue, Excel::XlAxisGroup::xlPrimary))-> \
					 TickLabels->NumberFormat = "#,##0";
			 }

			 //Other functions
	private: String^ sysTime()
			 {
				 struct tm *sysTime;
				 time(rawSysTime);
				 sysTime = localtime(rawSysTime);
				 String ^strSysTime = msclr::interop::marshal_as<System::String^>(asctime(sysTime));
				 return strSysTime;
			 }
	private: String^ To2Dig(int n)
			 {
				 String^ TwoDig="";
				 if(n/10==0)
					 TwoDig="0"+System::Convert::ToString(n);
				 else
					 TwoDig=System::Convert::ToString(n);
				 return TwoDig;
			 }
	private: String^ To2DP(double n)
			 {
				 if(!(n==n))
					 return "NAN";
				 String^ TwoDP;
				 int integer=n/1;
				 int decimal=0;
				 if(decimal*1000%10<5)
					 decimal = n*100-integer*100;
				 else
					 decimal = n*100-integer*100+1; 
				 TwoDP=System::Convert::ToString(integer)+"."+To2Dig(decimal);
				 return TwoDP;
			 }
	
			 //@author A0066758M
	private: void FillTransHist(DataGridView^ DG)
			 {
 				 updateToShow();
				 DG->Rows->Clear();

				 if(!(toShow->getTransList()->empty()))
				 {
					 list<Transaction*>::iterator iterT;
					 String ^SN, ^From, ^To, ^Cat, ^Amount, ^Date, ^Time;
					 for(iterT = toShow->getTransList()->begin(); iterT != toShow->getTransList()->end(); iterT++)
					 {
						 Date = System::Convert::ToString((*iterT)->getDateTime().year)+"."+System::Convert::ToString((*iterT)->getDateTime().month)+"."+System::Convert::ToString((*iterT)->getDateTime().day);
						 Time = To2Dig((*iterT)->getDateTime().hour)+":"+To2Dig((*iterT)->getDateTime().minute);
						 SN = System::Convert::ToString((*iterT)->getSerialNo());
						 if((*iterT)->getType() == INCOME)
						 {	
							 From = "-";
							 To = msclr::interop:: marshal_as<System::String^>((*iterT)->getAccount());
						 }
						 else if((*iterT)->getType() == EXPENSE)
						 {	
							 From = msclr::interop::marshal_as<System::String^>((*iterT)->getAccount());
							 To = "-";
						 }
						 else if((*iterT)->getType() == TRANSFER)
						 {
							 From = msclr::interop::marshal_as<System::String^>((*iterT)->getAccountFrom());
							 To = msclr::interop::marshal_as<System::String^>((*iterT)->getAccountTo());
						 }
						 Cat = msclr::interop::marshal_as<System::String^>((*iterT)->getCategory());
						 Amount = System::Convert::ToString((*iterT)->getAmount());
						 DG->Rows->Add(SN, Date, Time, Cat, Amount, From, To);
					 }
				 }
			 }
	private: void FillAccList(DataGridView^ DG) 
			 {
				 String^ Name, ^Balance, ^Warning;
				 DG->Rows->Clear();
				 list<string>::iterator iterA;
				 for(iterA=TM->getAccAddr()->begin(); iterA!=TM->getAccAddr()->end(); iterA++)
				 {
					 Warning = "";
					 if(*iterA!="delete")
					 {
						 Name = msclr::interop::marshal_as<System::String^>(*iterA);
						 Balance = System::Convert::ToString(TM->getAccBalance(*iterA));
						 if(System::Convert::ToDouble(Balance) < 50)
							 Warning = "!";
						 DG->Rows->Add(Name, Balance, Warning);
					 }
				 }
			 }
	private: void FillExpRep(DataGridView^ DG, History H)
			 {
				 double totExp = H.getTotalExpense();

				 list<History> catHistList;//record list of all categ hist
				 list<string>::iterator iterC;//go thru all categ
				 History tempCatHist;//store hist of a singel categ

				 DG->Rows->Clear();

				 if(!(TM->getCatAddr()->empty()))
				 { 

					 for(iterC=TM->getCatAddr()->begin(); iterC!=TM->getCatAddr()->end(); iterC++)
					 {
						 if(*iterC!="Income" && *iterC!="Transfer")
						 {
							 tempCatHist = H.filterCategory(*iterC);
							 catHistList.push_back(tempCatHist);
							 tempCatHist.clear();
						 }
					 }
				 }

				 list<History>::iterator iterH;//go thru all individual categ hist
				 String ^Name, ^Balance, ^Percent;
				 for(iterC=TM->getCatAddr()->begin(), iterH = catHistList.begin(); 
					 iterC != TM->getCatAddr()->end(); 
					 iterC++)
				 {
					 if(*iterC!="Income" && *iterC!="Transfer")
					 {
						 Name = msclr::interop::marshal_as<System::String^>(*iterC);
						 Balance = System::Convert::ToString(iterH->getTotalExpense());
						 Percent = To2DP(100.0*(iterH->getTotalExpense())/totExp);
						 DG->Rows->Add(Name, Balance, Percent);
						 iterH++;
					 }
				 }
			 }
			 	//@author A0091791X
	private: void setUpComboBox(string type, ComboBox^CB)
			 {
				 if(type=="acc")
				 {
					 CB->Items->Clear();
					 CB->Items->Add("All");
					 if(!((TM->getAccAddr())->empty()))
					 {
						 list<string>::iterator iterA;
						 String ^ tempAcc;
						 for(iterA = (TM->getAccAddr())->begin(); iterA != (TM->getAccAddr())->end(); iterA++)
						 {
							 if(*iterA!="delete")
							 {
								 tempAcc =  msclr::interop::marshal_as<System::String^>(*iterA);
								 CB->Items->Add(tempAcc);
							 }
						 }
						 CB->SelectedIndex = 0;
					 }
				 }
				 else if(type=="cat")
				 {
					 CB->Items->Clear();
					 CB->Items->Add("All");
					 if(!((TM->getCatAddr())->empty()))
					 {
						 list<string>::iterator iterC = TM->getCatAddr()->begin();
						 String ^ tempCat;
						 for(; iterC != (TM->getCatAddr())->end(); iterC++)
						 {
							 tempCat =  msclr::interop::marshal_as<System::String^>(*iterC);
							 CB->Items->Add(tempCat);
						 }
						 CB->SelectedIndex = 0;
					 }
				 }
				 else if(type=="hour")
				 {
					 struct tm *sysTime;
					 time_t *rawSysTime;
					 rawSysTime = new time_t;
					 time(rawSysTime);
					 sysTime = localtime(rawSysTime);
					 CB->SelectedIndex = sysTime->tm_hour;
					 delete rawSysTime;
				 }
				 else if(type=="min")
				 {
					 struct tm *sysTime;
					 time_t *rawSysTime;
					 rawSysTime = new time_t;
					 time(rawSysTime);
					 sysTime = localtime(rawSysTime);
					 CB->SelectedIndex = sysTime->tm_min;
					 delete rawSysTime;
				 }

				 else
					 return;
			 }
	private: void updateToShow()
			 {
				 History tempH;
				 tempH = TM->AllTransaction();
				 if(comboBox1->Text != "All")
					 tempH = tempH.filterAccount(msclr::interop::marshal_as<std::string>(comboBox1->Text));
				 if(comboBox2->Text != "All")
					 tempH = tempH.filterCategory(msclr::interop::marshal_as<std::string>(comboBox2->Text));

				 struct dateTime start, end;
				 start.year = dateTimePicker1->Value.Year;
				 start.month = dateTimePicker1->Value.Month;
				 start.day = dateTimePicker1->Value.Day;
				 end.year = dateTimePicker2->Value.Year;
				 end.month = dateTimePicker2->Value.Month;
				 end.day = dateTimePicker2->Value.Day;
				 start.hour = 0;
				 start.minute = 0;
				 end.hour = 23;
				 end.minute = 59;
				 tempH = tempH.filterDate(start, end);
				 *toShow = tempH;
			 }

	private: void refreshHome()
			 {
				 //sync sys time
				 label1->Text = sysTime();
				 struct tm *sysTime;
				 time(rawSysTime);
				 sysTime = localtime(rawSysTime);
				 int Y = sysTime->tm_year+1900;
				 int M = sysTime->tm_mon+1;
				 int D = sysTime->tm_mday;
				 //input monthly exp/inc
				 History currMonthHist;
				 currMonthHist = TM->currMonth(Y,M);
				 label5->Text = To2DP(currMonthHist.getTotalExpense());
				 label6->Text = To2DP(currMonthHist.getTotalIncome());
				 //input daily exp/inc
				 History todayHist;
				 todayHist = TM->today(Y,M,D);
				 label10->Text = To2DP(todayHist.getTotalExpense());
				 label11->Text = To2DP(todayHist.getTotalIncome());
			 }
	private: void refreshHistory()
			 {
				 if(TM->getActionStackSize()==0)
					 button16->Enabled=false;
				 else
					 button16->Enabled=true;
				 if(dataGridView1->Rows->Count == 0)
				 {
					 button13->Enabled=false;
					 button14->Enabled=false;
				 }
				 else
				 {
					 button13->Enabled=true;
					 button14->Enabled=true;
				 }
				 label32->Text=System::Convert::ToString(TM->getActionStackSize());

				 setUpComboBox("acc", comboBox1);
				 setUpComboBox("cat", comboBox2);
				 FillTransHist(dataGridView1);
			 }
	private: void refreshAccount()
			 {
				 History All = TM->AllTransaction();
				 double totBal = TM->getTotBalance();
				 label19->Text = To2DP(totBal);

				 FillAccList(dataGridView2);
			 }
	private: void refreshExpRep()
			 {
				 struct dateTime start, end;
				 start.year = dateTimePicker3->Value.Year;
				 start.month = dateTimePicker3->Value.Month;
				 start.day = dateTimePicker3->Value.Day;
				 end.year = dateTimePicker4->Value.Year;
				 end.month = dateTimePicker4->Value.Month;
				 end.day = dateTimePicker4->Value.Day;
				 start.hour = 0;
				 start.minute = 0;
				 end.hour = 23;
				 end.minute = 59;

				 History All = TM->AllTransaction();
				 All = All.filterDate(start, end);
				 double totExp = All.getTotalExpense();
				 label24->Text = To2DP(totExp);

				 FillExpRep(dataGridView3, All);
			 }
			//@author A0086933U
			 //I/O txt
	private: void retrieveACC(string delimitor)
			 {
				 ifstream readFile("Accounts.txt");
				 string oneLine;

				 string acctName;
				 double initialDeposit;

				 string acctVar[2];
				 if (readFile.is_open())
				 {
					 while(getline(readFile, oneLine))
					 {
						 istringstream iss(oneLine);

						 int start=0, end=0;
						 start=oneLine.find(delimitor);
						 for(int i=0; i<2; i++)
						 {
							 end = oneLine.find(delimitor, start+1);
							 if (end!=std::string::npos)
								 acctVar[i] = oneLine.substr(start+delimitor.size(), end-start-delimitor.size());
							 start = end;
						 }

						 acctName = acctVar[0];
						 initialDeposit = atof(acctVar[1].c_str());
						 TM->addAccount(acctName, initialDeposit);
					 }
				 }

				 readFile.close();
			 }
	private: void updateACC(string delimitor)
			 {
				 remove("Accounts.txt");
				 ofstream writeFile("Accounts.txt");

				 list<string>::iterator iterName;
				 list<double>::iterator iterDep;
				 for (iterName=TM->getAccAddr()->begin(), iterDep=TM->getAccDep()->begin(); 
					 iterName!=TM->getAccAddr()->end(); 
					 iterName++, iterDep++)
				 {
					 writeFile << delimitor << *iterName << delimitor << *iterDep << delimitor << endl;
				 }

				 writeFile.close();
			 }
	private: void retrieveCAT(string delimitor)
			 {
				 string categoryName;
				 ifstream readFile("Categories.txt");
				 string oneLine;
				 string catVar[2];
				 if (readFile.is_open())
				 {
					 while(getline(readFile, oneLine))
					 {
						 istringstream iss(oneLine);

						 int start=0, end=0;
						 start=oneLine.find(delimitor);
						 for(int i=0; i<1; i++)
						 {
							 end = oneLine.find(delimitor, start+1);
							 if (end!=std::string::npos)
								 catVar[i] = oneLine.substr(start+delimitor.size(), end-start-delimitor.size());
							 start = end;
						 }

						 categoryName = catVar[0];
						 TM->addCategory(categoryName);
					 }
				 }
				 readFile.close();
			 }
	private: void updateCAT(string delimitor)
			 {
				 remove("Categories.txt");
				 ofstream writeFile("Categories.txt");	
				 list<string>::iterator iterName;
				 for (iterName=TM->getCatAddr()->begin();iterName!=TM->getCatAddr()->end();iterName++)
				 {
					 writeFile << delimitor << *iterName << delimitor << endl;
				 }

				 writeFile.close();
			 }
	private: void retrieveTRAN(string delimitor)
			 {
				 int SN;
				 int type;
				 string account;
				 string accountFrom;
				 string accountTo;
				 string category;
				 int year,month,day,hour,min;
				 double amount;

				 Transaction *temp;

				 ifstream readFile("Transactions.txt");
				 string oneLine;

				 string transVar[12];
				 if (readFile.is_open())
				 {
					 while(getline(readFile, oneLine))
					 {
						 istringstream iss(oneLine);

						 int start=0, end=0;
						 start=oneLine.find(delimitor);
						 for(int i=0; i<11; i++)
						 {
							 end = oneLine.find(delimitor, start+1);
							 if (end!=std::string::npos)
								 transVar[i] = oneLine.substr(start+delimitor.size(), end-start-delimitor.size());
							 start = end;
						 }

						 type = atoi(transVar[0].c_str());
						 account = transVar[1];
						 accountFrom = transVar[2];
						 accountTo = transVar[3];
						 category = transVar[4];
						 year = atoi(transVar[5].c_str());
						 month = atoi(transVar[6].c_str());
						 day = atoi(transVar[7].c_str());
						 hour = atoi(transVar[8].c_str());
						 min = atoi(transVar[9].c_str());
						 amount = atof(transVar[10].c_str());

						 SN = *(TM->getSNAddr());
						 temp = new Transaction(amount, SN, year,month,day,hour,min, type, category, account, accountFrom,accountTo);
						 TM->addTransaction(temp);
					 }
				 }
				 readFile.close();
			 }
	private: void updateTRAN(string delimitor)
			 {
				 remove("Transactions.txt");
				 ofstream writeFile("Transactions.txt");
				 list<Transaction>::iterator iter;

				 for (iter=TM->getRecordAddr()->begin();iter!=TM->getRecordAddr()->end();iter++)
				 {
					 writeFile << delimitor << iter->getType() << delimitor << iter->getAccount() << delimitor << iter->getAccountFrom() << delimitor << iter->getAccountTo() << delimitor << iter->getCategory() << delimitor << iter->getDateTime().year<< delimitor <<iter->getDateTime().month<< delimitor <<iter->getDateTime().day<< delimitor <<iter->getDateTime().hour<< delimitor <<iter->getDateTime().minute << delimitor << iter->getAmount() << delimitor << endl;
				 }

				 writeFile.close();
			 }
	private: void retrieveALL(string delimitor)
			 {
				 retrieveACC(delimitor);
				 retrieveCAT(delimitor);
				 retrieveTRAN(delimitor);
				 TM->clearActionStack();
			 }
	private: void updateALL(string delimitor)
			 {
				 updateACC(delimitor);
				 updateCAT(delimitor);
				 updateTRAN(delimitor);
			 }

};
}
